/*
 * WindowListenerAdapter2.h
 *
 *  Created on: 2012-8-28
 *      Author: yangentao@gmail.com
 */

#ifndef WINDOWLISTENERADAPTER2_H_
#define WINDOWLISTENERADAPTER2_H_

#include <windows.h>
#include <boost/function.hpp>
#include "Window.h"

namespace ui {

class WindowListenerAdapter: public WindowMessageListener {
public:
	HRESULT onMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& handled);

	//WM_CREATE, HWND is created, but invisible, not return CreateWindow/CreateWindowEx
	//return true: continue; false: destroy the window
	boost::function<bool(HWND w, CREATESTRUCT* createStruct)> OnCreated;

	//WM_ACTIVATE
	//If the window is activated by a mouse click, it also receives a WM_MOUSEACTIVATE message
	//isActiving, true: active; false: inactive
	boost::function<void(bool isActiving, bool byMouse, bool isMinimize)> OnActivate;

	//return true: close the window;  false: prevent close window
	boost::function<bool(void)> OnClose;

	//WM_DESTROY is sent before the child windows are destroyed
	boost::function<void(void)> OnDestroy;

	//The WM_NCDESTROY message is sent after the child windows have been destroyed
	boost::function<void(void)> OnNcDestroy;

	//WM_KEYDOWN and WM_SYSKEYDOWN
	boost::function<void(bool altDown, bool ctrlDown, bool shiftDown, DWORD vKey, DWORD lParam, BOOL isRepeat, BOOL& handled)> OnKeyDown;

	//WM_KEYUP and WM_SYSKEYUP
	boost::function<void(bool altDown, bool ctrlDown, bool shiftDown, DWORD vKey, DWORD lParam, BOOL& handled)> OnKeyUp;

	//flag: SIZE_MAXHIDE/SIZE_MAXIMIZED/SIZE_MAXSHOW/SIZE_MINIMIZED/SIZE_RESTORED
	boost::function<void(UINT flag, WORD width, WORD height)> OnSize;

	//on WM_CREATE message, after onCreated invoked
	boost::function<void(void)> OnCreateChildren;

	//on WM_SIZE message, after onSize, after onCreateChildren
	boost::function<void(void)> OnLayoutChildren;

	//WM_COMMAND
	//for MENUINFO.dwStyle = MNS_NOTIFYBYPOS
	boost::function<void(HMENU menu, int itemPos)> OnMenuItemByPos;

	//WM_COMMAND
	//menuID may be 0 when user select the seprator menu item.
	boost::function<void(UINT menuID)> OnMenuItem;
	//WM_COMMAND
	boost::function<void(UINT accelID)> OnAccelerator;
	//WM_COMMAND
	boost::function<void(UINT controlMsg, UINT controlID, HWND control)> OnControl;

	//WM_SYSCOMMAND
	//wParam ==SC_CLOSE
	boost::function<void(void)> OnSystemClose;
	//WM_SYSCOMMAND
	boost::function<void(void)> OnSystemContextHelp;
	//WM_SYSCOMMAND//SC_KEYMENU, SC_MOUSEMENU
	boost::function<void(bool isMouse, int x, int y, int key)> OnSystemMenu;
	//WM_SYSCOMMAND
	boost::function<void(void)> OnSystemMaximize;
	//WM_SYSCOMMAND
	boost::function<void(void)> OnSystemMinimize;
	//WM_SYSCOMMAND
	boost::function<void(void)> OnSystemRestore;
	//WM_SYSCOMMAND
	boost::function<void(void)> OnSystemHScroll;
	//WM_SYSCOMMAND
	boost::function<void(void)> OnSystemVScroll;
	//WM_SYSCOMMAND
	boost::function<void(void)> OnSystemSizing;

	//WM_SYSCOMMAND//SC_TASKLIST
	//Activates the Start menu.
	boost::function<void(void)> OnSystemTaskList;
	//WM_SYSCOMMAND
	boost::function<void(void)> OnSystemMove;
	//WM_SYSCOMMAND
	boost::function<void(void)> OnSystemMovePre;
	//WM_SYSCOMMAND
	boost::function<void(void)> OnSystemMoveNext;
	//WM_SYSCOMMAND
	boost::function<void(void)> OnSystemDefault;
	//WM_SYSCOMMAND
	boost::function<void(HWND toActive)> OnSystemHotKey;
	//WM_SYSCOMMAND
	boost::function<void(void)> OnSystemScreenSave;
	//WM_SYSCOMMAND//lowPower or shutoff,
	boost::function<void(bool isLowPower, bool isShutOff)> OnSystemMonitorPower;

};

} /* namespace ui */
#endif /* WINDOWLISTENERADAPTER2_H_ */
